package edu;

import test.MyUtils;

/*
       *   多态、向上转型   演示示例程序（这里的乐器可是真的会发声的哦！）
   *   
 */
abstract class MusicalInstrument{  //乐器类
	abstract void play123();
}
class Violin extends MusicalInstrument{ //小提琴
	@Override
	void play123() {
		MyUtils.play123with("VIOLIN");
	} 
	
}
class Piano extends MusicalInstrument{ //钢琴
	@Override
	void play123() {
		MyUtils.play123with("PIANO");
	} 
}

class Guitar extends MusicalInstrument{ //吉他
	@Override
	void play123() {
		MyUtils.play123with("GUITAR");
	} 
}
public class PolymorphismTest001 {

	public static void main(String[] args) {
		MusicalInstrument  m1 = new Piano(); //向上转型
		m1.play123();
		
		MusicalInstrument  m2 = new Violin(); //向上转型
		m2.play123();
		
		MusicalInstrument  m3 = new Guitar(); //向上转型
		m3.play123();
	}

}
